<?php $this->load->helper('HTML');
echo link_tag('css/style2.css');
echo link_tag('images/favicon.ico','shortcut icon','image/x-icon');
?></head>
<div id="wrapper">
	<?php $this->load->view('admin_views/header'); ?><hr />
    <script type="text/javascript">
	  $(document).ready( function() {
    		$("#id_cabang").autocomplete({
      			minLength: 2,
      			source: 
        		function(req, add){
          			$.ajax({
		        		url: "<?php echo base_url(); ?>penjualan/lookupbabyKC",
		          		dataType: 'json',
		          		type: 'POST',
		          		data: req,
		          		success:    
		            	function(data){
		              		if(data.response =="true"){
		                 		add(data.message);
		              		}
		            	},
              		});
         		},
         	select: 
         		function(event, ui) {
            		$("#result3").append(
            			"<input type='hidden' id='intid_cabang' name='intid_cabang' value='" + ui.item.id + "' size='30' />"
            		);           		
         		},		
    		});
	    });
	</script>
</div>

	<div id="page">
	<div id="page-bgtop">
		<div id="content">
        <div class="post">
          <fieldset>
		<legend><strong>CETAK FEE BABY KEPALA CABANG</strong></legend>
        <form action="<?php echo base_url()?>laporan/fkc_baby" method="post">            
 		<table width="95%" border="0" cellpadding="0" cellspacing="0" id="data" align="center">
        	<tr>
            	<td>&nbsp;BULAN : </td>
                <td><select name="month">
                  <option value="">-- Pilih --</option>
                  <option value="01">JANUARI</option>
                  <option value="02">FEBRUARI</option>
                  <option value="03">MARET</option>
                  <option value="04">APRIL</option>
                  <option value="05">MEI</option>
                  <option value="06">JUNI</option>
                  <option value="07">JULI</option>
                  <option value="08">AGUSTUS</option>
                  <option value="09">SEPTEMBER</option>
                  <option value="10">OKTOBER</option>
                  <option value="11">NOVEMBER</option>
                  <option value="12">DESEMBER</option>                    
                </select></td>
                <td>&nbsp;<div id="result3"></div></td>
				
            </tr>
            <tr>
            	<td>&nbsp;CABANG : </td>
                <?php if ($id_cabang ==1) {
					echo '
                <td><input type="text" name="id_cabang" id="id_cabang"/></td>
                <td>&nbsp;<div id="result3"></div></td>';
				 } else { echo '
                <td><input type="text" name="cabang" id="cabang" value="'.$cabang.'"/>
                </td>
                <td>&nbsp;</td>
                 <input type="hidden" name="intid_cabang" id="intid_cabang" value="'.$id_cabang.'" readonly="readonly"/>'; } ?>
               
            </tr>
			
            <tr>
           		<th></th>
            	<td><input type="submit" value="Cetak" class="button"/>
        			 &nbsp;
              		<input class="button" type="button" value="Cancel" onclick="location.href='index';"/>
                </td>
           </tr>
		</table>	
        </form>    
        </fieldset>
        <div align="center">
        <?php echo $show_table;?>
        </div>
            
           
		  </div>
			</div>
			
		</div>
		<!-- end #content -->
		<?php $this->load->view('admin_views/sidebar_laporan'); ?><!-- end #sidebar -->
		<div style="clear: both;">&nbsp;</div>
	</div>
	</div>
	<!-- end #page -->
	<div id="footer-bgcontent">
	<?php $this->load->view('admin_views/footer'); ?></div>
	<!-- end #footer -->

//admin_view/laporan/print_fee_kc_baby_dif
<tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
                <?php
				$regD = 0;
				$hutD = 0;
				$har_hut = 0;
				$har_reg = 0;
				$reg_total = 0;
				$hut_total = 0;
								
				$omsetreg20=0;
				$omsetreg10=0;
				$omsetdealerreg=0;
				foreach ($Reg as $row):
					     $omsetreg20= $omsetreg20 + $row->TGroup20;
						 $omsetreg10= $omsetreg10 + $row->TGroup10;
				endforeach;	
				foreach ($RegDealer as $row1):
					     $omsetdealerreg= $omsetdealerreg + $row1->RegDealer;
				endforeach;	 
				?>
                <tr>
                	<td><?php echo $data_cabang->strkepala_cabang?></td>
                    <td><?php echo 'PIMPINAN';?></td>
                    <td><?php echo $data_cabang->strnama_cabang?></td>
                    <td>Reguler</td>
					
                    <td align="center"><?php echo (empty($omsetreg20))?'0':number_format($omsetreg20)?></td>
                    <td align="center"><?php echo (empty($omsetreg10))?'0':number_format($omsetreg10)?></td>
                    <td align="center">0</td>
                    <td align="center"><?php 
					$hdealer = ($omsetreg20 - ($omsetreg20*0.2)) + ($omsetreg10 - ($omsetreg10*0.1));
					echo (empty($hdealer))?'0':number_format($hdealer)?></td>
                    <td align="center"><?php echo (empty($hdealer))?'0':number_format(($hdealer) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($hdealer))?'0':number_format(($hdealer * $prs/100) * 5/100)?></td>
                    <td align="center"><?php 
					
					if(!empty($hdealer)){
						$regD = $hdealer;
						$har_reg =  (($hdealer) * $prs/100) - (($hdealer* $prs/100) * 5/100);
					
						echo (empty($har_reg))?'0':number_format($har_reg);
					}
					
					?></td>
                </tr>
                <?php 
				$omsethut20=0;
				$omsethut10=0;
				$omsetdealerhut=0;
				foreach ($Hut as $row2):
					     $omsethut20= $omsethut20 + $row2->TGroup20;
						 $omsethut10= $omsethut10 + $row2->TGroup10;
				endforeach;	
				foreach ($HutDealer as $row3):
					     $omsetdealerhut= $omsetdealerhut + $row3->HutDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td><?php echo $prs;?> persen</td>
                    <td>&nbsp;</td>
                    <td>Chall Hut</td>
                    <td align="center"><?php echo (empty($omsethut20))?'0':number_format($omsethut20)?></td>
                    <td align="center"><?php echo (empty($omsethut10))?'0':number_format($omsethut10)?></td>
                    <td align="center">0</td>
                    <td align="center"><?php $hdealerhut = ($omsethut20 - ($omsethut20*0.2)) + ($omsethut10 - ($omsethut10*0.1));
					echo (empty($hdealerhut))?'0':number_format($hdealerhut)?></td>
                    <td align="center"><?php echo (empty($hdealerhut))?'0':number_format(($hdealerhut) * $prs/100); $fhut=($hdealerhut * $prs)/100;?></td>
                    <td align="center"><?php echo (empty($hdealerhut))?'0':number_format(($fhut*5)/100);?></td>
                    <td align="center"><?php 
					
					if(!empty($hdealerhut)){
						$hutD = $hdealerhut;
						$har_hut = (($hdealerhut) * $prs/100) - (($hdealerhut* $prs/100) * 5/100);
						echo (empty($har_hut))?'0':number_format($har_hut);
					}
					?></td>
                </tr>
                <?php 
				$omsetcal20=0;
				$omsetcal10=0;
				$omsetdealercal=0;
				foreach ($Cal as $row4):
					     $omsettulipcal20= $omsettulipcal20 + $row4->TGroup20;
						 $omsettulipcal10= $omsettulipcal10 + $row4->TGroup10;
				endforeach;	
				foreach ($CalDealer as $row5):
					     $omsetdealercal= $omsetdealercal + $row5->CalDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Challenge</td>
                    <td align="center"><?php echo (empty($omsetcal20))?'0':number_format($omsetcal20)?></td>
                    <td align="center"><?php echo (empty($omsetcal10))?'0':number_format($omsetcal10)?></td>
                    <td align="center">0</td>
                    <td align="center"><?php $hdealercal = ($omsetcal20 - ($omsetcal20*0.2)) + ($omsetcal10 - ($omsetcal10*0.1));
					echo (empty($hdealercal))?'0':number_format($hdealercal)?></td>
                    <td align="center"><?php echo (empty($hdealercal))?'0':number_format(($hdealercal) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($hdealercal))?'0':number_format(($hdealercal * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$calD=0;
					$har_cal=0;
					if(!empty($hdealercal)){
						$calD = $hdealercal;
						$har_cal = (($hdealercal) * $prs/100) - (($hdealercal* $prs/100) * 5/100);
						echo (empty($har_cal))?'0':number_format($har_cal);
					}
					?></td>
                </tr>
                <?php 
				$omsettin20=0;
				$omsettin10=0;
				$omsetdealertin=0;
				foreach ($tin as $row6):
					     $omsettin20= $omsettin20 + $row6->TGroup20;
						 $omsettin10= $omsettin10 + $row6->TGroup10;
				endforeach;	
				foreach ($tinDealer as $row7):
					     $omsetdealertin= $omsetdealertin + $row7->tinDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Trade In</td>
                    <td align="center"><?php echo (empty($omsettin20))?'0':number_format($omsettin20)?></td>
                    <td align="center"><?php echo (empty($omsettin10))?'0':number_format($omsettin10)?></td>
                    <td align="center">0</td>
                    <td align="center"><?php $hdealertin = ($omsettin20 - ($omsettin20*0.2)) + ($omsettin10 - ($omsettin10*0.1));
					echo (empty($hdealertin))?'0':number_format($hdealertin)?></td>
                    <td align="center"><?php echo (empty($hdealertin))?'0':number_format(($hdealertin) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($hdealertin))?'0':number_format(($hdealertin * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$tinD=0;
					$har_tin=0;
					if(!empty($hdealertin)){
						$tinD = $hdealertin;
						$har_tin = (($hdealertin) * $prs/100) - (($hdealertin* $prs/100) * 5/100);
						echo (empty($har_tin))?'0':number_format($har_tin);
					}
					?></td>
                </tr>
                <?php 
				$omsetifi=0;
				$omsetdealerifi=0;
				foreach ($ifi as $row8):
					     $omsetifi= $omsetifi + $row8->inttotal_omset;
				endforeach;	
				foreach ($ifiDealer as $row9):
					     $omsetdealerifi= $omsetdealerifi + $row9->ifiDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>1 Free 1 Hut/Nett</td>
                    <td align="center">0</td>
                  <td align="center">0</td>
                    <td align="center"><?php echo (empty($omsetifi))?'0':number_format($omsetifi)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifi))?'0':number_format($omsetdealerifi)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifi))?'0':number_format(($omsetdealerifi) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerifi))?'0':number_format(($omsetdealerifi * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$ifiD=0;
					$har_ifi=0;
					if(!empty($omsetdealerifi)){
						$ifiD = $omsetdealerifi;
						$har_ifi = (($omsetdealerifi) * $prs/100) - (($omsetdealerifi* $prs/100) * 5/100);
						echo (empty($har_ifi))?'0':number_format($har_ifi);
					}
					?></td>
                </tr>
                 <?php 
				$omsetifo10=0;
				$omsetdealerifo=0;
				foreach ($ifo as $row10):
					     $omsetifo10= $omsetifo10 + $row10->TGroup10;
				endforeach;	
				foreach ($ifoDealer as $row11):
					     $omsetdealerifo= $omsetdealerifo + $row11->ifoDealer;
				endforeach;	 
				?>
                 <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>1 Free 1 10%</td>
                    <td align="center">0</td>
                    <td align="center"><?php echo (empty($omsetifo10))?'0':number_format($omsetifo10)?></td>
                    <td align="center">0</td>
                    <td align="center"><?php $hdealerifo = ($omsetifo10 - ($omsetifo10*0.1));
					echo (empty($hdealerifo))?'0':number_format($hdealerifo)?></td>
                    <td align="center"><?php echo (empty($hdealerifo))?'0':number_format(($hdealerifo) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($hdealerifo))?'0':number_format(($hdealerifo * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$ifoD=0;
					$har_ifo=0;
					if(!empty($hdealerifo)){
						$ifoD = $hdealerifo;
						$har_ifo = (($hdealerifo) * $prs/100) - (($hdealerifo* $prs/100) * 5/100);
						echo (empty($har_ifo))?'0':number_format($har_ifo);
					}
					?></td>
                </tr>
                <?php 
				$omsetnet=0;
				$omsetdealernet=0;
				foreach ($net as $row12):
					     $omsetnet= $omsetnet + $row12->inttotal_omset;
				endforeach;	
				foreach ($netDealer as $row13):
					     $omsetdealernet= $omsetdealernet + $row13->netDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Netto</td>
                    <td align="center">0</td>
                    <td align="center">0</td>
                    <td align="center"><?php echo (empty($omsetnet))?'0':number_format($omsetnet)?></td>
                    <td align="center"><?php echo (empty($omsetdealernet))?'0':number_format($omsetdealernet)?></td>
                    <td align="center"><?php echo (empty($omsetdealernet))?'0':number_format(($omsetdealernet) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealernet))?'0':number_format(($omsetdealernet * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$netD=0;
					$har_net=0;
					if(!empty($omsetdealernet)){
						$netD = $omsetdealernet;
						$har_net = (($omsetdealernet) * $prs/100) - (($omsetdealernet* $prs/100) * 5/100);
						echo (empty($har_net))?'0':number_format($har_net);
					}
					?></td>
                </tr>
                <?php 
				$omsetsp=0;
				$omsetdealersp=0;
				foreach ($sp as $row14):
					     $omsetsp= $omsetsp + $row14->inttotal_omset;
				endforeach;	
				foreach ($spDealer as $row15):
					     $omsetdealersp= $omsetdealersp + $row15->netDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Special Price</td>
                    <td align="center">0</td>
                    <td align="center">0</td>
                    <td align="center"><?php echo (empty($omsetsp))?'0':number_format($omsetsp)?></td>
                    <td align="center"><?php echo (empty($omsetdealersp))?'0':number_format($omsetdealersp)?></td>
                    <td align="center"><?php echo (empty($omsetdealersp))?'0':number_format(($omsetdealersp) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealersp))?'0':number_format(($omsetdealersp * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$spD=0;
					$har_sp=0;
					if(!empty($omsetdealersp)){
						$spD = $omsetdealersp;
						$har_sp = (($omsetdealersp) * $prs/100) - (($omsetdealersp* $prs/100) * 5/100);
						echo (empty($har_sp))?'0':number_format($har_sp);
					}
					?></td>
                </tr>
                <?php 
				$omsetp=0;
				$omsetdealerp=0;
				foreach ($p as $row16):
					     $omsetp= $omsetp + $row16->inttotal_omset;
						 
				endforeach;	
				foreach ($pDealer as $row31):
					     $omsetdealerp= $omsetdealerp + $row31->netDealer;
				endforeach;	 
				?>
                <tr>
                	<td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>Point</td>
                    <td align="center">0</td>
                    <td align="center">0</td>
                    <td align="center"><?php echo (empty($omsetp))?'0':number_format($omsetp)?></td>
                    <td align="center"><?php echo (empty($omsetdealerp))?'0':number_format($omsetdealerp)?></td>
                    <td align="center"><?php echo (empty($omsetdealerp))?'0':number_format(($omsetdealerp) * $prs/100)?></td>
                    <td align="center"><?php echo (empty($omsetdealerp))?'0':number_format(($omsetdealerp * $prs/100)*5/100)?></td>
                    <td align="center"><?php 
					$pD=0;
					$har_p=0;
					if(!empty($omsetdealerp)){
						$pD = $omsetdealerp;
						$har_p = (($omsetdealerp) * $prs/100) - (($omsetdealerp* $prs/100) * 5/100);
						echo (empty($har_p))?'0':number_format($har_p);
					}
					?></td>
                </tr>